/**
 * Copyright：2020，TLF工作室。
 */
package com.cqeec.netdisc.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cqeec.netdisc.model.User;

/**
 * 用户Mapper。
 * 
 * @author 唐礼飞
 * 
 * @date 2020-10-11 10:12:47
 *
 */
@Mapper
public interface UserMapper {
	@Insert("INSERT INTO User(id,name,loginName,password,email,creationTime) VALUES(#{id},#{name},#{loginName},#{password},#{email},#{creationTime})")
	public void insert(User user);

	@Select("SELECT * FROM User WHERE (name=#{name} OR loginName=#{name}) AND password=#{password}")
	public User findLoginUser(@Param("name") String name, @Param("password") String password);

	@Select("SELECT COUNT(*) FROM User WHERE id=#{id} AND password=#{password}")
	public int checkUserPassword(@Param("id") String id, @Param("password") String password);

	@Update("UPDATE User SET password=#{password} WHERE id=#{id}")
	public void updatePassword(@Param("id") String id, @Param("password") String password);
}
